package team.seekers.catering.common.enums;

import com.baomidou.mybatisplus.core.enums.IEnum;
import lombok.Getter;

import java.util.Arrays;

/**
 * 派送员段位枚举
 */
@Getter
public enum GradeEnum implements IEnum<Integer> {

    USER1(1, "青铜", "0.5",0),
    USER2(2, "白银", "0.55",1),
    USER3(3, "黄金", "0.65",10),
    USER4(4, "钻石", "0.7",50),
    USER5(5, "王者", "0.8",200);

    private int type;

    private String name;

    private String percentage;

    private Integer orderNumber;

    GradeEnum(int type, String name, String percentage, Integer orderNumber) {
        this.type = type;
        this.name = name;
        this.percentage = percentage;
        this.orderNumber = orderNumber;
    }

    @Override
    public Integer getValue() {
        return this.type;
    }

    public static GradeEnum getByType(int type) {
        return Arrays.stream(values()).filter(e -> e.getType() == type).findFirst().orElse(null);
    }

    public static GradeEnum getByName(String name) {
        return Arrays.stream(values()).filter(e -> e.getName().equals(name)).findFirst().orElse(null);
    }
}
